// create dynamically: 
// var ct = new contacts.ContactCard"({name :  "Koch", surname: "Thomas", org: "OrbiTeam"}, theWidgetsDomNode);
// or define in HTML
 // <div dojoType="contacts.ContactCard" name="Koch" surname="Thomas" ></div>
  
dojo.provide("contacts.ContactCard");

dojo.require("dijit._Widget");
dojo.require("dijit._Templated");

dojo.declare(
        "contacts.ContactCard",
        [dijit._Widget, dijit._Templated],
    {
	templateString: "<div class='contact'>\
		<span class='contact_button'>[<a href='#' dojoAttachEvent='onclick:doit'>X</a>]</span> 	\
		<span class='contact_data'>${surname} ${lname}</span><br/>\
		<span class='contact_data'>${org}</span><br/>\
		<span class='contact_data'>${email}</span></div>",
		
	lname   : "",
	surname : "",
	email   : "",
	org     : "Acme Corp.",  // default value

	doit: function() {			
		this.destroyRecursive();
	},
		
	postMixInProperties: function() {
		console.log("postMixInProperties: email="+this.email);
		if (this.email)
			this.email = '<a href="mailto:'+this.email+'">'+ this.email + '</a>';
		this.inherited(arguments);
	}

    }
);
